package org.finesys.quartz.support;

import static org.finesys.common.quartz.core.constants.SchedulerConstants.SCHEDULE_JOB_KEY;

import org.finesys.quartz.entity.SysJob;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.lang.NonNull;
import org.springframework.scheduling.quartz.QuartzJobBean;

import lombok.RequiredArgsConstructor;

/**
 * 并行执行
 */
@RequiredArgsConstructor
public class QuartzJobParallelBean extends QuartzJobBean {

    private final QuartzInvokeFactory quartzInvokeFactory;

    @Override
    protected void executeInternal(@NonNull JobExecutionContext context) throws JobExecutionException {
        SysJob sysJob = (SysJob) context.getMergedJobDataMap().get(SCHEDULE_JOB_KEY);
        quartzInvokeFactory.sendQuartzJob(sysJob, context);
    }
}
